/**
 * @author LKQ
 * @date 2022/2/26 10:01
 * @description 买股票题类型1
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int maximumDifference(int[] nums) {
        int minPrice = Integer.MAX_VALUE;
        int max = 0;
        for(int i = 0; i < nums.length; i++) {
            if(nums[i] < minPrice) {
                minPrice = nums[i];
            }else if(nums[i] - minPrice > max) {
                max = nums[i] - minPrice;
            }
        }
        return max == 0 ? -1 : max;
    }
}
